from xml.dom.minidom import parse;

xmlAct = parse("./ActTest.xml");
actCollection = xmlAct.documentElement;
actElements = actCollection.getElementsByTagName("activity");

for actItem in actElements:
    print "*Activity:";
    print "id:", actItem.getAttribute("id");
    print "name:", actItem.getAttribute("name");
    if actItem.getAttribute("subject")!="":
        print "subject:", str(actItem.getAttribute("subject").replace("[","").replace("]","")).split(",");
    if actItem.getAttribute("object")!="":
        print "object:", str(actItem.getAttribute("object").replace("[","").replace("]","")).split(",");
    print "time:", str(actItem.getAttribute("time").replace("[","").replace("]","")).split(",");
    print "parents:", actItem.getAttribute("parents");
    print "score:", actItem.getAttribute("score");
    print "location:", actItem.getAttribute("location");
    subjectElements = actItem.getElementsByTagName("subject");
    for subjectItem in subjectElements:
        print "_subject:", subjectItem.firstChild.data;
        if subjectItem.getAttribute("time")!="":
            print "_time:", str(subjectItem.getAttribute("time").replace("[","").replace("]","")).split(",");
        print "_type:", subjectItem.getAttribute("type");
        print "";
    objectElements = actItem.getElementsByTagName("object");
    for objectItem in objectElements:
        print "_object:", objectItem.firstChild.data;
        print "_time:", str(objectItem.getAttribute("time").replace("[","").replace("]","")).split(",");
        print "_type:", objectItem.getAttribute("type");
        print "";
    subActElements = actItem.getElementsByTagName("sub-activity");
    for subActItem in subActElements:
        print "    *SubActivity:";
        print "    id:", actItem.getAttribute("id");
        print "    name:", actItem.getAttribute("name");
        print "    subject:", str(actItem.getAttribute("subject").replace("[","").replace("]","")).split(",");
        print "    object:", str(actItem.getAttribute("object").replace("[","").replace("]","")).split(",");
        print "    time:", str(actItem.getAttribute("time").replace("[","").replace("]","")).split(",");
        print "    parents:", actItem.getAttribute("parents");
        print "    score:", actItem.getAttribute("score");
        print "    location:", actItem.getAttribute("location");
        